var assert = require('assert');
var should = require('should');
var util = require('util');
var _ = require('lodash');
var skillModel = require('../../app/models/skillModel');
var config = require('../config');
var mongoConnector = require('../../app/libs/mongodb/mongoConnector');
var Skill = mongoConnector().model('Skill');
var PlayerManager = require('../../app/libs/playerManager.js');

suite('测试skillModel', function () {
    var skill_model;
    var player_manager = new PlayerManager(config.role_id);
    setup(function (done) {
        Skill.remove({
            role_id: config.role_id
        }, function (err) {
            if (err) {
                return handleError(err);
            }

            player_manager.getModel(['skill'], function (err) {
                assert.equal(err == null, true);
                skill_model = player_manager.skill;
                done();
            });
        });
    });

    // suite('getByRoleId', function () {
    //     test('获取数据错误', function (done) {
    //         skillModel.getByRoleId('***', function (err, model) {
    //             done();
    //         });
    //     });
    // });

    suite('addSkill', function () {
        // test('添加技能失败', function (done) {
        //     skill_model.addSkill(1000).should.eql(false);
        //     skill_model.save(function () {
        //         done();
        //     });
        // });

        test('添加技能成功', function (done) {
            skill_model.skill_list = [];
            skill_model.addSkill(1001).should.eql(true);
            skill_model.addSkill(1001).should.eql(false);
            skill_model.save(function () {
                done();
            });
        });
    });

    suite('getSkill', function () {
        test('获取技能', function () {
            skill_model.getSkill(1000);
        });
    });

    suite('upgradeSkill', function () {
        test('升级技能失败', function () {
            skill_model.upgradeSkill(1000);
        });

        test('升级技能成功', function () {
            skill_model.addSkill(1001);
            skill_model.upgradeSkill(1001).should.eql(true);
        });
    });

    suite('initSkillList', function () {
        test('初始化技能列表', function () {
            skill_model.initSkillList(1);
        });
    });
});
